package com.lanmao.blog.service.impl;

import com.lanmao.blog.entity.Views;
import com.lanmao.blog.mapper.ViewsMapper;
import com.lanmao.blog.service.ViewsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lanmao.blog.vo.WeekViews;
import jdk.nashorn.internal.objects.NativeUint8Array;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lanmao
 * @since 2022-03-28
 */
@Service
public class ViewsServiceImpl extends ServiceImpl<ViewsMapper, Views> implements ViewsService {

    @Override
    public List<WeekViews> getByweek() {
        List<WeekViews> list=baseMapper.getByWeek();
        return list;
    }

    @Override
    public WeekViews getTodayViews() {
        Date date = new Date();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        String s = format.format(date);
        WeekViews weekViews= baseMapper.getTodayViews(s);
        return weekViews;
    }

    @Override
    public String listofViews() {
       String views= baseMapper.listofViews();
       return views;
    }
}
